//
//  ZHRightView.m
//  Doctor
//
//  Created by liuzhishan on 15/12/15.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHRightView.h"
#import "ZHClinicModel.h"


@interface ZHRightView () 

@property (nonatomic,retain) UILabel *lableTitle;
@property (nonatomic,retain) UILabel *lableUp;
@property (nonatomic,retain) UILabel *lableDown;
@property (nonatomic,retain) UIButton *btnDetails;

@end

@implementation ZHRightView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addMyChildViews] ;
        
    }
    return self;
}

-(void)addMyChildViews
{
    UIImageView *imageBg = [[UIImageView alloc]init];
    imageBg.image = [UIImage imageNamed:@"transparentH"];
    [self addSubview:imageBg];
    self.image = imageBg;
    
    UILabel *lableTitle = [[UILabel alloc]init];
    [lableTitle setMyFramewithX:26 andY:20 andWidth:150 andHeight:50];
    lableTitle.textColor = [UIColor whiteColor];
    lableTitle.font = [UIFont systemFontOfSize:30*WIDPro - 2];
    [self addSubview:lableTitle];
    self.lableTitle = lableTitle;
    
    
    UIImageView *bgimage1 = [[UIImageView alloc]init];
    [bgimage1 setMyFramewithX:135 andY:107 andWidth:210 andHeight:3];
    bgimage1.image = [UIImage imageNamed:@"clinic-blue"];
    [self addSubview:bgimage1];
    
    UIImageView *bgimage2 = [[UIImageView alloc]init];
    [bgimage2 setMyFramewithX:238 andY:170 andWidth:150 andHeight:3];
    bgimage2.image = [UIImage imageNamed:@"clinic-orange"];
    [self addSubview:bgimage2];
    
    self.lableUp = [[UILabel alloc]init];
    [self.lableUp setMyFramewithX:260 andY:85 andWidth:90 andHeight:20];
    self.lableUp.font= [UIFont systemFontOfSize:17 * WIDPro - 2];
    self.lableUp.textAlignment = NSTextAlignmentRight;
    self.lableUp.textColor = [UIColor whiteColor];
    [self addSubview:self.lableUp];
    
    
    
    self.lableDown = [[UILabel alloc]init];
    [self.lableDown setMyFramewithX:300 andY:150 andWidth:90 andHeight:20];
    self.lableDown.textColor = [UIColor whiteColor];
    self.lableDown.textAlignment = NSTextAlignmentRight;
    self.lableDown.font = [UIFont systemFontOfSize:17 * WIDPro - 2];
    [self addSubview:self.lableDown];

    
    UIButton *btnDetails = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnDetails setMyFramewithX:462 andY:240 andWidth:90 andHeight:40];
    [btnDetails setBackgroundImage:[UIImage imageNamed:@"clinic-details"] forState:UIControlStateNormal];
    
    [btnDetails addTarget:self action:@selector(btnClick) forControlEvents:(UIControlEventTouchUpInside)];

    
    
    [self addSubview:btnDetails];
    
    
    
 
    self.lableClinicUp = [[UILabel alloc]init];
    [self.lableClinicUp setMyFramewithX:135 andY:110 andWidth:0 andHeight:20];
    self.lableClinicUp.textColor = [UIColor whiteColor];
    self.lableClinicUp.font= [UIFont systemFontOfSize:17 * WIDPro - 2];
    [self addSubview:self.lableClinicUp];
    
    self.lableClinicDown = [[UILabel alloc]init];
    [self.lableClinicDown setMyFramewithX:238 andY:175 andWidth:0 andHeight:20];
    self.lableClinicDown.textColor = [UIColor whiteColor];
    self.lableClinicDown.font= [UIFont systemFontOfSize:17 * WIDPro - 2];
    [self addSubview:self.lableClinicDown];
    
    
}

-(void)btnClick
{
    
    
    
     if ([_titleName isEqualToString:@"诊所收入"]) {
         
         [self.dele pushMyChooseController:2];
         
     }
    
    else
    {
        [self.dele pushMyChooseController:3];
    }
}

-(void)setTitleName:(NSString *)titleName
{
    _titleName = titleName;
    
    self.lableTitle.text = titleName;

}


-(void)setModel:(ZHClinicModel *)model
{
    _model = model;
    
    if ([_titleName isEqualToString:@"诊所收入"]) {
        
        self.lableUp.text = [NSString stringWithFormat:@"%@",model.allIncome];
        
        self.lableDown.text = [NSString stringWithFormat:@"%@",model.topPrice];
        
        
        if (model.allIncome == nil) {
            
            self.lableUp.text= @"0";
            
        }
        if (model.topPrice == nil) {
            
            self.lableDown.text = @"0";
        }

        
        
    }
    
    else
    {
       
        
        self.lableUp.text = [NSString stringWithFormat:@"%@",model.firstVisit];
        self.lableDown.text = [NSString stringWithFormat:@"%@",model.secondVisit];
        
        if (model.firstVisit == nil) {
            
            self.lableUp.text= @"0";
            
        }
        if (model.secondVisit == nil) {
            
            self.lableDown.text = @"0";
        }
        

    }
    
    
    //self.btnDetails.userInteractionEnabled = YES;
    
    
}

@end
